package top.codedance.iotp.tools.serverTool.ui;

import top.codedance.iotp.tools.terminal.ui.ShellFrame;

import javax.swing.*;
import java.awt.*;
import java.net.URL;

/**
 *
 * @author Lenovo
 */
public class MainFrame extends javax.swing.JDialog {
    private ShellFrame sf;

    /**
     * Creates new form MainFrame
     */
    public MainFrame(ShellFrame sf) {
        super(sf, true);
        this.sf = sf;
        initComponents();
        URL url = Thread.currentThread().getContextClassLoader().getResource("logo.gif");
        ImageIcon icon = new ImageIcon(url);
        setIconImage(icon.getImage());
        setMinimumSize(new Dimension(900, 643));
        setLocationRelativeTo(this.sf);
        setTitle("代码飞舞采控系统-服务器管理工具");
    }

    public ShellFrame getShellFrame(){
        return sf;
    }

    public void setStatus(String status){
        jl_status.setText(status);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jp_information = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jb_viewRegistServer = new javax.swing.JButton();
        hex2ascii = new javax.swing.JButton();
        genDeviceIdsBtn = new javax.swing.JButton();
        jl_status = new javax.swing.JLabel();
        jb_selectServer = new javax.swing.JButton();
        viewRemoteStatusBtn = new javax.swing.JButton();
        viewOnlineDevicesBtn = new javax.swing.JButton();
        addDeviceToRemoteBtn = new javax.swing.JButton();
        viewDeviceListBtn = new javax.swing.JButton();
        addUserToRemoteBtn = new javax.swing.JButton();
        viewUserListBtn1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setSize(new java.awt.Dimension(900, 643));
        getContentPane().setLayout(new java.awt.GridLayout(3, 4, 1, 1));

        jp_information.setBackground(new java.awt.Color(183, 183, 183));

        jLabel1.setForeground(new java.awt.Color(153, 0, 0));
        jLabel1.setText("注：");

        jLabel2.setForeground(new java.awt.Color(0, 102, 51));
        jLabel2.setText("1、添加设备与用户后需在服务器");

        jLabel3.setForeground(new java.awt.Color(0, 102, 0));
        jLabel3.setText("上Console进行刷新缓存");

        jLabel4.setForeground(new java.awt.Color(0, 0, 102));
        jLabel4.setText("2、所有服务地址最后不要加 /");

        jLabel5.setForeground(new java.awt.Color(102, 0, 102));
        jLabel5.setText("3、如果服务端开启加密，需使用");

        jLabel6.setForeground(new java.awt.Color(102, 0, 102));
        jLabel6.setText("对应密钥加密");

        javax.swing.GroupLayout jp_informationLayout = new javax.swing.GroupLayout(jp_information);
        jp_information.setLayout(jp_informationLayout);
        jp_informationLayout.setHorizontalGroup(
            jp_informationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jp_informationLayout.createSequentialGroup()
                .addGroup(jp_informationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jp_informationLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel1))
                    .addGroup(jp_informationLayout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(jp_informationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jp_informationLayout.setVerticalGroup(
            jp_informationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jp_informationLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addContainerGap(62, Short.MAX_VALUE))
        );

        getContentPane().add(jp_information);

        jb_viewRegistServer.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        jb_viewRegistServer.setText("查看注册中心中的服务");
        jb_viewRegistServer.setActionCommand("");
        jb_viewRegistServer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_viewRegistServerActionPerformed(evt);
            }
        });
        getContentPane().add(jb_viewRegistServer);

        hex2ascii.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        hex2ascii.setActionCommand("hex2ascii");
        hex2ascii.setLabel("Hex-ASCII互转");
        hex2ascii.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hex2asciiActionPerformed(evt);
            }
        });
        getContentPane().add(hex2ascii);

        genDeviceIdsBtn.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        genDeviceIdsBtn.setLabel("生成设备ID");
        genDeviceIdsBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                genDeviceIdsBtnActionPerformed(evt);
            }
        });
        getContentPane().add(genDeviceIdsBtn);

        jl_status.setBackground(new java.awt.Color(51, 51, 51));
        jl_status.setFont(new java.awt.Font("微软雅黑", 1, 14)); // NOI18N
        jl_status.setForeground(new java.awt.Color(255, 255, 255));
        jl_status.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jl_status.setText("当前选取的连接：[默认]");
        jl_status.setOpaque(true);
        getContentPane().add(jl_status);

        jb_selectServer.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        jb_selectServer.setText("选取SEFVER");
        jb_selectServer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_selectServerActionPerformed(evt);
            }
        });
        getContentPane().add(jb_selectServer);

        viewRemoteStatusBtn.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        viewRemoteStatusBtn.setLabel("查看服务端状态");
        viewRemoteStatusBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewRemoteStatusBtnActionPerformed(evt);
            }
        });
        getContentPane().add(viewRemoteStatusBtn);

        viewOnlineDevicesBtn.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        viewOnlineDevicesBtn.setActionCommand("viewOnlineDevices");
        viewOnlineDevicesBtn.setLabel("查看在线设备");
        viewOnlineDevicesBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewOnlineDevicesBtnActionPerformed(evt);
            }
        });
        getContentPane().add(viewOnlineDevicesBtn);

        addDeviceToRemoteBtn.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        addDeviceToRemoteBtn.setLabel("添加设备到服务端");
        addDeviceToRemoteBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addDeviceToRemoteBtnActionPerformed(evt);
            }
        });
        getContentPane().add(addDeviceToRemoteBtn);

        viewDeviceListBtn.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        viewDeviceListBtn.setActionCommand("viewDeviceListBtn");
        viewDeviceListBtn.setLabel("查看设备列表");
        viewDeviceListBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewDeviceListBtnActionPerformed(evt);
            }
        });
        getContentPane().add(viewDeviceListBtn);

        addUserToRemoteBtn.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        addUserToRemoteBtn.setLabel("添加用户到服务端");
        addUserToRemoteBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addUserToRemoteBtnActionPerformed(evt);
            }
        });
        getContentPane().add(addUserToRemoteBtn);

        viewUserListBtn1.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        viewUserListBtn1.setActionCommand("viewUserListBtn");
        viewUserListBtn1.setLabel("查看用户列表");
        viewUserListBtn1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewUserListBtn1ActionPerformed(evt);
            }
        });
        getContentPane().add(viewUserListBtn1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void genDeviceIdsBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genDeviceIdsBtnActionPerformed
        GenDeviceFrame gdf = new GenDeviceFrame(this);
        gdf.setVisible(true);
    }//GEN-LAST:event_genDeviceIdsBtnActionPerformed

    private void addDeviceToRemoteBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addDeviceToRemoteBtnActionPerformed
        AddDeviceFrame addDeviceFrame = new AddDeviceFrame(this);
        addDeviceFrame.setVisible(true);
    }//GEN-LAST:event_addDeviceToRemoteBtnActionPerformed

    private void addUserToRemoteBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addUserToRemoteBtnActionPerformed
        AddUserFrame addUserFrame = new AddUserFrame(this);
        addUserFrame.setVisible(true);
    }//GEN-LAST:event_addUserToRemoteBtnActionPerformed

    private void viewRemoteStatusBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewRemoteStatusBtnActionPerformed
        ServerInfoFrame sif = new ServerInfoFrame(this);
        sif.setVisible(true);
    }//GEN-LAST:event_viewRemoteStatusBtnActionPerformed

    private void viewDeviceListBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewDeviceListBtnActionPerformed
        DeviceListFrame dlf = new DeviceListFrame(this);
        dlf.setVisible(true);
    }//GEN-LAST:event_viewDeviceListBtnActionPerformed

    private void viewUserListBtn1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewUserListBtn1ActionPerformed
        UserListFrame ulf = new UserListFrame(this);
        ulf.setVisible(true);
    }//GEN-LAST:event_viewUserListBtn1ActionPerformed

    private void viewOnlineDevicesBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewOnlineDevicesBtnActionPerformed
        ViewOnlineDevicesFrame vodf = new ViewOnlineDevicesFrame(this);
        vodf.setVisible(true);
    }//GEN-LAST:event_viewOnlineDevicesBtnActionPerformed

    private void hex2asciiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hex2asciiActionPerformed
        Hex2AsciiFrame haf = new Hex2AsciiFrame(this);
        haf.setVisible(true);
    }//GEN-LAST:event_hex2asciiActionPerformed

    private void jb_selectServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_selectServerActionPerformed
        SelectConnectFrame scf = new SelectConnectFrame(this);
        scf.setVisible(true);
    }//GEN-LAST:event_jb_selectServerActionPerformed

    private void jb_viewRegistServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_viewRegistServerActionPerformed
        ViewRegistInfomation vri = new ViewRegistInfomation(this);
        vri.setVisible(true);
    }//GEN-LAST:event_jb_viewRegistServerActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addDeviceToRemoteBtn;
    private javax.swing.JButton addUserToRemoteBtn;
    private javax.swing.JButton genDeviceIdsBtn;
    private javax.swing.JButton hex2ascii;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JButton jb_selectServer;
    private javax.swing.JButton jb_viewRegistServer;
    private javax.swing.JLabel jl_status;
    private javax.swing.JPanel jp_information;
    private javax.swing.JButton viewDeviceListBtn;
    private javax.swing.JButton viewOnlineDevicesBtn;
    private javax.swing.JButton viewRemoteStatusBtn;
    private javax.swing.JButton viewUserListBtn1;
    // End of variables declaration//GEN-END:variables
}
